1
|
|
|
const Inquire = require('./Inquire'); |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* ReactRaise class |
5
|
|
|
* @class ReactRaise |
6
|
|
|
*/ |
7
|
|
|
class ReactRaise { |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Creates an instance of ReactRaise. |
11
|
|
|
* @memberOf ReactRaise |
12
|
|
|
*/ |
13
|
|
|
constructor() { |
14
|
|
|
this.privateProps = new WeakMap(); |
15
|
|
|
this.privateProps.set(this, { |
16
|
|
|
setupInfo: {}, |
17
|
|
|
}); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* set or alter the private properties; |
22
|
|
|
* @param {String} key - key of item to set |
23
|
|
|
* @param {any} value - value to store inside private property |
24
|
|
|
* @returns {object} set private properties |
25
|
|
|
* @memberOf ReactRaise |
26
|
|
|
*/ |
27
|
|
|
setProp(key, value) { |
28
|
|
|
return this.privateProps.set( |
29
|
|
|
this, |
30
|
|
|
Object.assign({}, this.privateProps.get(this), { [key]: value }) |
31
|
|
|
); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* get the private properties; |
36
|
|
|
* @param {String} key - key of item to get |
37
|
|
|
* @returns {object} set private properties |
38
|
|
|
* @memberOf ReactRaise |
39
|
|
|
*/ |
40
|
|
|
getProp(key) { |
41
|
|
|
return this.privateProps.get(this)[key]; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* initialize command and ask setup questions |
46
|
|
|
* @param {Function} callback - function to execute after answers has been given |
47
|
|
|
* @returns {Void} returns nothing |
48
|
|
|
* @memberOf ReactRaise |
49
|
|
|
*/ |
50
|
|
|
init(callback) { |
51
|
|
|
const startInquire = new Inquire(); |
52
|
|
|
startInquire.question('description', 'input', 'Can you describe your app[optional]'); |
53
|
|
|
startInquire.question( |
54
|
|
|
'main', |
55
|
|
|
'input', |
56
|
|
|
'What is the main entry file of your app[Default: index.js]'); |
57
|
|
|
startInquire.question('author', 'input', 'What is your name[optional]'); |
58
|
|
|
startInquire.question( |
59
|
|
|
'license', |
60
|
|
|
'input', |
61
|
|
|
'What is license is your app under[Default: MIT]' |
62
|
|
|
); |
63
|
|
|
startInquire.question( |
64
|
|
|
'express', |
65
|
|
|
'input', |
66
|
|
|
'Do you want to configure an express server with this app(y/n)', |
67
|
|
|
'yesNo' |
68
|
|
|
); |
69
|
|
|
|
70
|
|
|
startInquire.ask((information) => { |
71
|
|
|
this.setProp('setupInfo', information); |
72
|
|
|
if (callback) { |
73
|
|
|
callback(); |
74
|
|
|
} |
75
|
|
|
}); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
module.exports = ReactRaise; |
80
|
|
|
|